Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix output stream operator #376

Merged
merged 7 commits into from
Feb 17, 2022
Merged

Fix output stream operator #376

merged 7 commits into from
Feb 17, 2022

Conversation

jennuine
Copy link
Contributor

@jennuine jennuine commented Feb 9, 2022

🦟 Bug fix

Part of gazebosim/sdformat#790

(See section (2) of gazebosim/sdformat#790 (comment))

Summary

The output stream would change the value when calling precision(). This causes issues changing the precision of the output stream.

For example,

math::Vector3d test(1.5707963267948966, 0, 0);
std::cout << test;
// prints 1.5708 0 0

std::cout << std::setprecision(std::numeric_limits<double>::digits10) 
              << test; 
// prints 1.5707960000000001 0 0; x should be 1.5707963267949

Since there doesn't seem to be a clear reason to why the value is changed and the default precision is already 6, I've deprecated the function that changes the value appendToStream(std::ostream &_out, T _number, int _precision) to be replaced with appendToStream(std::ostream &_out, T _number).

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Signed-off-by: Jenn Nguyen <[email protected]>
@jennuine jennuine requested a review from azeey February 9, 2022 19:18
@github-actions github-actions bot added the 🌱 garden Ignition Garden label Feb 9, 2022
Signed-off-by: Jenn Nguyen <[email protected]>
@codecov
Copy link

codecov bot commented Feb 9, 2022

Codecov Report

Merging #376 (85b07d5) into main (0b48b73) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #376   +/-   ##
=======================================
  Coverage   99.63%   99.63%           
=======================================
  Files          65       65           
  Lines        6103     6111    +8     
=======================================
+ Hits         6081     6089    +8     
  Misses         22       22           
Impacted Files Coverage Δ
include/ignition/math/Color.hh 100.00% <100.00%> (ø)
include/ignition/math/Helpers.hh 99.30% <100.00%> (+0.04%) ⬆️
include/ignition/math/Matrix3.hh 100.00% <100.00%> (ø)
include/ignition/math/Matrix4.hh 100.00% <100.00%> (ø)
include/ignition/math/Vector2.hh 100.00% <100.00%> (ø)
include/ignition/math/Vector3.hh 100.00% <100.00%> (ø)
include/ignition/math/Vector4.hh 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b48b73...85b07d5. Read the comment docs.

Copy link
Contributor

@azeey azeey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Do you mind adding checks to the OperatorStreamOut test of each of these classes to ensure that the precision set on the stream object is used properly? Right now the tests only cover appendToStream for individual numbers.

src/Helpers_TEST.cc Show resolved Hide resolved
@jennuine
Copy link
Contributor Author

Do you mind adding checks to the OperatorStreamOut test of each of these classes to ensure that the precision set on the stream object is used properly?

2f63681

Copy link
Contributor

@azeey azeey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with green CI! See #374 (review) about OrientedBox_TEST.

Signed-off-by: Jenn Nguyen <[email protected]>
@jennuine
Copy link
Contributor Author

LGTM with green CI! See #374 (review) about OrientedBox_TEST.

Thanks! 2560b0b

Signed-off-by: Jenn Nguyen <[email protected]>
@jennuine jennuine merged commit 04028c9 into main Feb 17, 2022
@jennuine jennuine deleted the jennuine/ostream_fix branch February 17, 2022 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 garden Ignition Garden
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants